<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/static/pear/admin/css/other/console1.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="reload" action="">
            <div class="layui-form-item">

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="">注册方式</option>
                            <option value="1">后台导入</option>
                            <option value="2">现场注册</option>
                        </select>
                    </div>
                </div>
                <input type="hidden" name="userid" value="{$userid}">
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="keys"  placeholder="请输入课程名称|班级名称" class="layui-input" autocomplete="off">
                    </div>
                </div>

                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class=" layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            <li>
                <a href="/MembersTotal/qxt?userid={$userid}">轻学堂课程</a>
            </li>
            <li>
                <a href="/MembersTotal/book?userid={$userid}">轻学堂书籍</a>
            </li>
            <li class="layui-this">线下班级</li>

            <li>
                <a href="/MembersTotal/learning?userid={$userid}">E-learning</a>
            </li>
            <li>
                <a href="/MembersTotal/live?userid={$userid}">直播课</a>
            </li>
        </ul>
        <div class="layui-card-body">
            <table id="user-table" lay-filter="user-table"></table>
        </div>
    </div>
</div>
<script type="text/html" id="user-bar">
    <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="view"><i class="layui-icon layui-icon-search"></i></button>
</script>
{include file="_Fragment/javascript" /}
<script>
    layui.use(['table', 'form', 'jquery','common'], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let userid = "{$userid}";

        let cols = [
            [
                {
                    title: '课程',
                    field: 'seminar',
                    align: 'center',
                },
                {
                    title: '班级',
                    field: 'class_title',
                    align: 'center',
                },
                {
                    title: '学习时长(S)',
                    field: 'time',
                    align: 'center',
                },
                {
                    title: '学习进度',
                    field: 'progress',
                    align: 'center',
                },
                {
                    title: '注册方式',
                    field: 'reg_type_name',
                    align: 'center',
                },
                {
                    title: '签到时间',
                    field: 'sign_time',
                    align: 'center',
                },
                {
                    title: '操作',
                    toolbar: '#user-bar',
                    align: 'center',
                }
            ]
        ]

        table.render({
            elem: '#user-table',
            url: '/MembersTotal/getLearnnowList?userid='+userid,
            page: {layout:['count', 'prev', 'page', 'next', 'skip']},
            limit: 5,
            cols: cols,
            //skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter',{
                title: '导出' //标题
                ,layEvent: 'export' //事件名，用于 toolbar 事件中使用
                ,icon: 'layui-icon-export' //图标类名
            }]
        });
        form.on('submit(user-query)', function(data) {
            table.reload('user-table', {
                where: data.field
                ,page: {
                    curr: 1, //重新从第 1 页开始
                    layout:['count', 'prev', 'page', 'next', 'skip']
                }
                ,limit: 5,
            })
            return false;
        });


        table.on('tool(user-table)', function(obj) {
            if (obj.event === 'view') {
                window.view(obj);
            }
        });


        table.on('toolbar(user-table)', function(obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'export') {
                window.export();
            }
        });


        window.view = function(obj) {
            layer.open({
                type: 2,
                title: '详情',
                shade: 0.1,
                area: [common.isModile()?'100%':'900px', common.isModile()?'100%':'600px'],
                content: '/MembersTotal/learnnowView?class_id='+obj.data.class_id+'&userid='+userid
            });
        }


        // 数据导出
        window.export = function() {
            var field = form.val('reload');
            layer.confirm('确定要导出员工数据吗?', {
                icon: 3,
                title: '提示'
            }, function(index) {
                layer.close(index);
                window.open("{:url('exportLearnnow')}?status="+field.status+"&userid="+field.userid+"&keys="+field.keys, "_blank");
            });
        };

        window.refresh = function(param) {
            table.reload('user-table');
        }

    })
</script>
</body>
</html>
